import requests
import re
import os

#爬取路径
u = input("Web URl:")

#目标输出路径
f = ''
if not os.path.exists(f):
    os.mkdir(f)

url = u
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36'}
res1 = requests.get(url=url,headers=headers)
res1.encoding = 'utf-8'

#print(res1.request.headers)
#print(res1.status_code)
#print(res1.text)

#目标网页元素
a = '<img src="(.*?)" class="img-responsive DownMusicPNG" alt="(.*?)">'
result = re.findall(a,res1.text)
print(result)
for img in result:
    print(img)
    m = f + '/' + img[1].split('-')[0]
    if not os.path.exists(m):
        os.mkdir(m)
    res = requests.get('https://www.everyonepiano.com' +img[0])
    print(res.status_code)
    with open(m + '/' + img[1] + '.' + 'png',mode="wb") as file:
        file.write(res.content)